import datetime

birthday = "1989-11-24"
#创建日期对象，实例化
birthday_date = datetime.datetime.strptime(birthday, "%Y-%m-%d")
print(birthday_date, type(birthday_date))

curr_datetime = datetime.datetime.now()
print(curr_datetime, type(curr_datetime))

minus_datetime = curr_datetime - birthday_date
print(minus_datetime, type(minus_datetime))

print(f"出生日期：{birthday_date}，当前日期{curr_datetime}，相差{minus_datetime.days}天。")
print(f"出生日期：{birthday_date}，当前日期{curr_datetime}，相差{minus_datetime.days/365:.1f}年。")
print(f"出生日期：{birthday_date}，当前日期{curr_datetime}，相差{round(minus_datetime.days/365, 1)}年。")